예제 #1
0
 public override void Init(CUIPanel oCanvas, CProp oProp)
 {
     _oTextLabel = transform.GetChild(0).GetComponent<Text>();           // Label is always first child
     _oSlider = transform.GetChild(1).GetComponent<Slider>();            // Slider always second child
     _oTextValue = _oSlider.transform.GetChild(2).GetChild(0).GetChild(0).GetComponent<Text>();      // Value text at that relative address.  ###WEAK
     _oSlider.minValue = oProp._nMin;
     _oSlider.maxValue = oProp._nMax;
     base.Init(oCanvas, oProp);
 }
예제 #2
0
 public static CUIDropdown Create(CUIPanel oCanvas, CProp oProp, FieldInfo[] aFieldsEnum)
 {
     GameObject oDropdownResGO = Resources.Load("UI/CUIDropdown") as GameObject;
     GameObject oDropdownGO = Instantiate(oDropdownResGO) as GameObject;
     oDropdownGO.transform.SetParent(oCanvas.transform, false);
     CUIDropdown oUIDropdown = oDropdownGO.GetComponent<CUIDropdown>();
     oUIDropdown.Init(oCanvas, oProp, aFieldsEnum);
     return oUIDropdown;
 }
예제 #3
0
 public static CUIButton Create(CUIPanel oCanvas, CProp oProp)
 {
     GameObject oButtonResGO = Resources.Load("UI/CUIButton") as GameObject;
     GameObject oButtonGO = Instantiate(oButtonResGO) as GameObject;
     oButtonGO.transform.SetParent(oCanvas.transform, false);
     CUIButton oUIButton = oButtonGO.GetComponent<CUIButton>();
     oUIButton.Init(oCanvas, oProp);
     return oUIButton;
 }
예제 #4
0
 public static CUIToggle Create(CUIPanel oCanvas, CProp oProp)
 {
     GameObject oToggleResGO = Resources.Load("UI/CUIToggle") as GameObject;
     GameObject oToggleGO = Instantiate(oToggleResGO) as GameObject;
     oToggleGO.transform.SetParent(oCanvas.transform, false);
     CUIToggle oUIToggle = oToggleGO.GetComponent<CUIToggle>();
     oUIToggle.Init(oCanvas, oProp);
     return oUIToggle;
 }
예제 #5
0
 public static CUISlider Create(CUIPanel oCanvas, CProp oProp)
 {
     //####IMPROVE: Can abstract some of this to base?
     GameObject oSliderResGO = Resources.Load("UI/CUISlider") as GameObject;                 //####IMPROVE: Cache
     GameObject oSliderGO = Instantiate(oSliderResGO) as GameObject;
     oSliderGO.transform.SetParent(oCanvas.transform, false);
     CUISlider oUISlider = oSliderGO.GetComponent<CUISlider>();
     oUISlider.Init(oCanvas, oProp);
     return oUISlider;
 }
예제 #6
0
 public virtual void Init(CUIPanel oCanvas, CProp oProp)
 {
     _oCanvas = oCanvas;
     _oProp = oProp;
     if (_oProp == null)
         Debug.Log("CUIWidget.Init has null property!!");
     _oTextLabel.text = oProp._sLabel;
     SetValue(_oProp.PropGet());
     _bInitialized = true;
 }
예제 #7
0
파일: CKeyHook.cs 프로젝트: dvochin/Scripts
    float _nPropValueStart; // Value of our CProp at start of 'quick mouse edit'

    #endregion Fields

    #region Constructors

    public CKeyHook(CProp oProp, KeyCode oKeyCode, EKeyHookType eKeyHookType, string sDescription, float nRatio=1.0f, bool bSelectedBodyOnly = true)
    {
        _oProp			= oProp;
        _oKeyCode		= oKeyCode;
        _eKeyHookType	= eKeyHookType;
        _sDescription	= sDescription;
        _nRatio			= nRatio;
        _bSelectedBodyOnly = bSelectedBodyOnly;
        _oWeakRef		= new WeakReference(this, false);
        CGame.INSTANCE._aKeyHooks.Add(_oWeakRef);		//###NOTE: Add a weak reference to CGame so that it can automatically remove dead objects as the owner of this CKeyHook destroys us.
    }
예제 #8
0
    public void WriteProperty(CProp oProp)
    {
        // Serialize_OBS a single CProp property onto existing script record file.  Basically records the 'transactions' that user-action pushes onto the scene

        float nTime = Time.time;
        float nTimeDelta = nTime - _nTimeLastScriptWrite;
        if (nTimeDelta > 3) nTimeDelta = 3;		//###DESIGN: Keep max??
        _nTimeLastScriptWrite = nTime;
        string sScriptLine = string.Format("Set({0:F2}, Body.{1}, '{2}', {3:F3});", nTimeDelta, oProp._oObject._sNameScriptHandle, oProp._sNameProp, oProp._nValueLocal);
        //Debug.Log(sScriptLine);
        _oStreamWriterScriptFile.WriteLine(sScriptLine);
    }
예제 #9
0
파일: CObject.cs 프로젝트: dvochin/Scripts
 //---------------------------------------------------------------------------	EVENTS
 public void Notify_PropertyValueChanged(CProp oProp, float nValueOld)
 {
     //###LEARN: How to implement events
     EventArgs_PropertyValueChanged oEventArgs = new EventArgs_PropertyValueChanged();
     oEventArgs.Property = oProp;
     oEventArgs.PropertyID = oProp._nPropEnumOrdinal;
     oEventArgs.PropertyName = oProp._sNameProp;
     oEventArgs.ValueNew = oProp._nValueLocal;
     oEventArgs.ValueOld = nValueOld;
     EventHandler<EventArgs_PropertyValueChanged> oHandler = Event_PropertyValueChanged;
     if (oHandler != null)
         oHandler(this, oEventArgs);
 }
예제 #10
0
 public void Init(CUIPanel oCanvas, CProp oProp, FieldInfo[] aFieldsEnum)
 {
     _oTextLabel = transform.GetChild(0).GetComponent<Text>();           // Label is always first child of prefab
     _oDropdown  = transform.GetChild(1).GetComponent<Dropdown>();       // Dropdown is always 2nd child of prefab
     //_oDropdown.options.RemoveAll();
     foreach (FieldInfo oFieldInfo in aFieldsEnum) {
         if (oFieldInfo.Name != "value__") {               // Enums have a hidden 'value__' entry.  Don't add it to drop box...
             Dropdown.OptionData oOptData = new Dropdown.OptionData(oFieldInfo.Name);
             _oDropdown.options.Add(oOptData);
         }
     }
     base.Init(oCanvas, oProp);
     _oDropdown.value = -1;                  //###LEARN: Original setting of drop down won't 'take' if we first don't set to other value than start value.
     base.Init(oCanvas, oProp);              //###WEAK: We must init twice for above call to work
 }
예제 #11
0
파일: CObject.cs 프로젝트: dvochin/Scripts
    public string _sBlenderAccessString; // The fully-qualified 'Blender Access String' where we can obtain our Blender-based CObject equivalent designed to communicate with this Unity-side object.

    #endregion Fields

    #region Constructors

    public CObjectBlender(IObject iObj, string sBlenderAccessString, int nBodyID)
        : base(iObj, nBodyID, sBlenderAccessString)
    {
        //###NOW object name!
        _sBlenderAccessString = sBlenderAccessString;

        string sSerializedCSV = CGame.gBL_SendCmd("CBody", _sBlenderAccessString + ".Serialize()");            //###MOVE#11 to another blender codefile?

        string[] aFields = CUtility.SplitCommaSeparatedPythonListOutput(sSerializedCSV);

        _sNameObject = aFields[0];
        int nProps = int.Parse(aFields[1]);
        _aProps = new CProp[nProps];
        CPropGroup oPropGrp = PropGroupBegin("", "", true);			//###CHECK#11: OK?  Group name?  Change default group functionality to auto insert of zero?

        for (int nProp = 0; nProp < nProps; nProp++) {
            sSerializedCSV = CGame.gBL_SendCmd("CBody", _sBlenderAccessString + ".SerializeProp(" + nProp.ToString() + ")");
            aFields = CUtility.SplitCommaSeparatedPythonListOutput(sSerializedCSV);
            string sName            = aFields[0];
            string sDescription     = aFields[1];
            float nValue            = float.Parse(aFields[2]);
            float nMin              = float.Parse(aFields[3]);
            float nMax              = float.Parse(aFields[4]);
            //int eFlags              = int  .Parse(aFields[5]);
            _aProps[nProp] = new CProp(this, nProp, sName, nValue, nMin, nMax, sDescription, 0, null);//, CProp.Blender, null);	//###NOTE: No longer a Blender property as we don't update every slider value change for better performance (we batch update during mode change now)
            oPropGrp._aPropIDs.Add(nProp);
            _aProps[nProp]._sNameProp = sName;              //###HACK!!!
            _aProps[nProp]._nValueLocal = nValue;              //###HACK!!!
        }
        //float nValue2 = _aProps[1].PropGet();
        //nValue2 = _aProps[1].PropSet(4);
        //nValue2 = _aProps[0].PropSet(0);
        //nValue2 = _aProps[0].PropSet(4);
    }
예제 #12
0
파일: CObject.cs 프로젝트: dvochin/Scripts
 //---------------------------------------------------------------------------	PROP ADD
 public CProp PropAdd(object oPropEnumOrdinal, string sLabel, float nDefault, float nMin, float nMax, string sDescription, int nPropFlags = 0, Type oTypeChoice = null)
 {
     //###DESIGN!!!!: _aPropsOnGUI retains holes if not added?  What to do???
     int nPropEnumOrdinal = (int)oPropEnumOrdinal;
     CProp oProp = new CProp(this, nPropEnumOrdinal, sLabel, nDefault, nMin, nMax, sDescription, nPropFlags, oTypeChoice);
     _aProps[nPropEnumOrdinal] = oProp;
     if (_oPropGroup_LastAdded != null)
         _oPropGroup_LastAdded._aPropIDs.Add(nPropEnumOrdinal);		//###TODO: Remove, etc
     return oProp;
 }
예제 #13
0
 public override void Init(CUIPanel oCanvas, CProp oProp)
 {
     _oButton = GetComponent<Button>();                              // Button is our node
     _oTextLabel = transform.GetChild(0).GetComponent<Text>();       // Label is always 1st child of prefab
     base.Init(oCanvas, oProp);
 }
예제 #14
0
 public override void Init(CUIPanel oCanvas, CProp oProp)
 {
     _oToggle = GetComponent<Toggle>();                              // Toggle is our node
     _oTextLabel = transform.GetChild(1).GetComponent<Text>();       // Label is always 2nd child of prefab
     base.Init(oCanvas, oProp);
 }