Hi,
I create a class that have few properties for example “color,height and …”. then I attached that class into tow objects by name “A” and “B”, now how can i change value of a property from “B” when property in “A” change?
If you want the property to be synced across all GameObjects which has your MonoBehavior class attached, then you could give the class a static field and just have the property reference that field.
thank you, but I don’t want the property to be synced across all GameObjects, I explain more
class Columns
{
var affectedColumnLenth:int;
var selectedColumn:GameObject;
public var columnCurentSituation:int;//-1 =down , 1=top
function get ColumnCurentSituation():int
{
return columnCurentSituation;
}
function set ColumnCurentSituation(value:int)
{
columnCurentSituation=value;
}
function up()
{
columnCurentSituation=1;
print("UP");
}
function down()
{
columnCurentSituation=-1;
print("Down");
}
function ColumnUpAndDown(columnCurentSituation,affectedColumns)
{
if(columnCurentSituation==-1)
{
up();
}
if(columnCurentSituation==1)
{
down();
}
}
}
var column:Columns;
var affectedColumns:Columns[];
function OnMouseDown()
{
column.ColumnUpAndDown(column.columnCurentSituation,column.affectedColumns);
for(var i:int=0;i<column.affectedColumnLenth;i++)
{
if(affectedColumns*.columnCurentSituation==1)*
-
{*
-
//*
-
}*
_ if(affectedColumns*.columnCurentSituation==-1)_
_ {_
_ //_
_ }*_
_ affectedColumns*.columnCurentSituation=-column.columnCurentSituation;
print(affectedColumns.selectedColumn.name.ToString());
}*_
}
for example attach this code to tow object “A” and “B”
in below code “columnCurentSituation” change only “A” when I click on “A”, I want columnCurentSituation change in “B” too.
affectedColumns*.columnCurentSituation=-column.columnCurentSituation;*
any help?